import React, { Component } from 'react';
import FooterPage from '@components/layout/footerPage';
import axios from 'axios';
// import labRules from 'web/index';

class Labrules extends Component {
    constructor(props) {
        super(props);
        this.state = { labRules: [] };
      }
    
    componentDidMount() {
    const handleError = (error) => {
        console.error(error);
    };
    const handleException = (exception) => {
        console.error(exception);
    };

    axios.get('http://localhost:8080/web/lab_rules/list', {})
        .then((response) => {
        this.setState({ labRules:  response.data.data});
    
        })
        .catch(handleError)
        .catch(handleException);
    }

    render() {

      const { labRules } = this.state;
      console.log(labRules)

    return (
          <div>
            {labRules.map((rule) => (
              <div key={rule.id}>
                <h3>{rule.name}</h3>
                <p>{rule.text}</p>
              </div>
            ))}
          </div>
    );
  }
}

export default Labrules;